//
//  MNDBaofuBankListCell.m
//  minidai
//
//  Created by Steven.Yung on 2017/6/8.
//  Copyright © 2017年 迷你金服. All rights reserved.
//

#import "MNDBaofuBankListCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface MNDBaofuBankListCell ()

@property (weak, nonatomic) IBOutlet UIImageView *bankLogo;
@property (weak, nonatomic) IBOutlet UILabel *bankNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *quotaLabel;

@end

@implementation MNDBaofuBankListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setBankListModel:(MNDBaofuBankListModel *)bankListModel {
    _bankListModel = bankListModel;
    
    self.bankNameLabel.text = bankListModel.vc_bank_name;
    
    double singleQuota = bankListModel.vc_single_quota.doubleValue / 10000;
    NSString *singleQuotaStr = singleQuota >= 1 ? [NSString stringWithFormat:@"%1.lf万", singleQuota] : [NSString stringWithFormat:@"%.1lf万", singleQuota];
    
    double dayQuota = bankListModel.vc_daily_quota.doubleValue / 10000;
    NSString *dayQuotaStr = dayQuota >= 1 ? [NSString stringWithFormat:@"%1.lf万", dayQuota] : [NSString stringWithFormat:@"%.1lf万", dayQuota];
    
    double monthQuota = bankListModel.vc_menstrual_quota.doubleValue / 10000;
    NSString *monthQuotaStr = monthQuota >= 1 ? [NSString stringWithFormat:@"%1.lf万", monthQuota] : [NSString stringWithFormat:@"%.1lf万", monthQuota];
    
    if (bankListModel.vc_single_quota.doubleValue <= 0) {
        singleQuotaStr = @"无限额";
    }
    if (bankListModel.vc_daily_quota.doubleValue <= 0) {
        dayQuotaStr = @"无限额";
    }
    if (bankListModel.vc_menstrual_quota.doubleValue <= 0) {
        monthQuotaStr = @"无限额";
    }
    
    self.quotaLabel.text = [NSString stringWithFormat:@"单笔%@, 单日%@, 单月%@", singleQuotaStr, dayQuotaStr, monthQuotaStr];
    
    [self.bankLogo sd_setImageWithURL:[NSURL URLWithString:bankListModel.vc_bank_img] placeholderImage:[UIImage imageNamed:@"bank_logo_placeholder"]];
}






@end
